package praktikum_2_ylesanded.ylesanne_1;

import javax.xml.soap.Node;
import java.util.LinkedList;

/**
 * Created by IntelliJ IDEA.
 * User: Jaan Sepp and Martti Elias
 * Date: 2.10.11
 * Time: 11:30
 */
public class Stack {
  ListNode head ;
  int listSize;

  public Stack(){
    head = new ListNode(null, 0);
    listSize = 0;
  }

  public void push(int x){
     ListNode node = new ListNode(head, x);
     head = node;
     listSize++;
  }

  public int pop(){
    int firstInStack = head.getNodeValue();
    head = head.getNextNode();
    listSize--;
    return firstInStack;
  }
  public boolean isEmpty(){
    return listSize == 0;
  }
}
